﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace uTrade.Core
{
    public class Order
    {
        /// <summary>
        /// 报单操作
        /// </summary>
        [Description("报单操作列表"), Category("交易")]
        public List<OrderItem> Operations { get; private set; } = new List<OrderItem>();
    }

    /// <summary>
    /// 交易报单
    /// </summary>
    public class OrderItem
    {
        //在策略中被赋值
        internal int IndexEntryLong;

        internal int IndexLastEntryLong;
        internal int IndexExitShort;
        internal int IndexEntryShort;
        internal int IndexExitLong;
        internal int IndexLastEntryShort;

        /// <summary>
        /// 时间
        /// </summary>
        [Description("时间:yyyyMMdd.HHmmss"), Category("字段"), ReadOnly(true)]
        public DateTime DateTiem { get; set; }

        /// <summary>
        /// 买卖
        /// </summary>
        [Description("买卖"), Category("字段"), ReadOnly(true)]
        public Direction Dir { get; set; }

        /// <summary>
        /// 开平
        /// </summary>
        [Description("开平"), Category("字段"), ReadOnly(true)]
        public Offset Offset { get; set; }

        ///
        /// 价格
        /// </summary>
        [Description("价格"), Category("字段"), ReadOnly(true)]
        public double Price { get; set; }

        /// <summary>
        /// 手数
        /// </summary>
        [Description("手数"), Category("字段"), ReadOnly(true)]
        public int Lots { get; set; }

        /// <summary>
        /// 注释
        /// </summary>
        [Description("说明"), Category("字段"), ReadOnly(true)]
        public string Remark { get; set; }

        //internal double ExitTimeLong { get; set; }

        //internal double ExitTimeShort { get; set; }

        //internal double LastEntryTimeShort { get; set; }

        //internal double EntryTimeShort { get; set; }

        //internal double LastEntryTimeLong { get; set; }

        /// <summary>
        /// 当前持仓平均建仓价格:空
        /// </summary>
        internal double AvgEntryPriceShort { get; set; }

        /// <summary>
        /// 当前持仓首个建仓到当前位置的Bar数:多(从0开始计数)
        /// </summary>
        internal double AvgEntryPriceLong { get; set; }

        /// <summary>
        /// 当前持仓手数:多
        /// </summary>
        internal int PositionLong { get; set; }

        /// <summary>
        /// 当前持仓手数:空
        /// </summary>
        internal int PositionShort { get; set; }

        /// <summary>
        /// 当前持仓首个建仓时间:多(yyyyMMdd.HHmmss)
        /// </summary>
        internal double EntryDateLong { get; set; }

        //internal double EntryTimeLong { get; set; }

        /// <summary>
        /// 当前持仓首个建仓价格:多
        /// </summary>
        internal double EntryPriceLong { get; set; }

        ///<summary>
        ///	最近平仓时间:空(yyyyMMdd.HHmmss)
        ///</summary>
        internal double ExitDateShort { get; set; }

        /// <summary>
        /// 最近平仓价格:空
        /// </summary>
        internal double ExitPriceShort { get; set; }

        /// <summary>
        /// 当前持仓首个建仓时间:空(yyyyMMdd.HHmmss)
        /// </summary>
        internal double EntryDateShort { get; set; }

        /// <summary>
        /// 当前持仓首个建仓价格:空
        /// </summary>
        internal double EntryPriceShort { get; set; }

        /// <summary>
        /// 最近平仓时间:多(yyyyMMdd.HHmmss)
        /// </summary>
        internal double ExitDateLong { get; set; }

        /// <summary>
        /// 最近平仓价格:多
        /// </summary>
        internal double ExitPriceLong { get; set; }

        /// <summary>
        /// 当前持仓最后建仓时间:空(yyyyMMdd.HHmmss)
        /// </summary>
        internal double LastEntryDateShort { get; set; }

        /// <summary>
        /// 当前持仓最后建仓价格:空
        /// </summary>
        internal double LastEntryPriceShort { get; set; }

        /// <summary>
        /// 当前持仓最后建仓时间:多(yyyyMMdd.HHmmss)
        /// </summary>
        internal double LastEntryDateLong { get; set; }

        /// <summary>
        /// 当前持仓最后建仓价格:多
        /// </summary>
        internal double LastEntryPriceLong { get; set; }
    }
}